/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package botlab.control;

import com.jme3.scene.Spatial;
import com.jme3.scene.control.Control;

/**
 *
 * @author Quentin
 */
public abstract class BaseTimerControl extends BaseControl
{
    private float timeout;
    private float time;
    private boolean finished;
    
    public BaseTimerControl(float seconds)
    {
        timeout=seconds;
        time=0f;
        finished=false;
    }

    @Override
    protected void controlUpdate(float tpf)
    {
        if(!finished)
        {
            time+=tpf;
            if(time>timeout)
            {
                finished=true;
                time=0f;
                timeIsUp();
            }
        }
            
    }
    
    protected abstract void timeIsUp();

    @Override
    public Control cloneForSpatial(Spatial spatial)
    {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
